﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sofire.Data;
using Sofire.Data.Profilers;
using System.Data;
using System.Data.Common;

namespace DataCommTest.DataTest
{
    public class DataTestDemo : ITest
    {
        #region ITest 成员

        public void Test()
        {
            System.IO.File.Delete("test.db");
            QueryProfiler.Add(Share.Engine);
            Share.Engine.ExecuteNonQuery("CREATE TABLE MyUsers(Username varchar(20) PRIMARY KEY,password varchar(20))");

            using(var context = Share.Engine.Context)
            {
                context.OpenTransaction();

                for(int i = 0 ; i < 10 ; i++)
                {
                    context.ExecuteNonQuery("INSERT INTO MyUsers(Username,Password) VALUES(@uid,@pwd)"
                                                      , "@uid", "userUIDXX" + i
                                                      , "@pwd", "userPWDXX");
                    if(i == 4)
                    {
                        context.Commit();
                    }
                }
                context.Rollback();
            }
        }

        #endregion

        public void Test2()
        {
            //var context = UserEntity.Manager
          
        }
    }



}
